Skip to content

feat(newsletter): newsletter status handling#2435

Open
Maciej D (mdanilowicz) wants to merge 1 commit intomainfrom
feat/GH-2327-ii
Open

feat(newsletter): newsletter status handling#2435
Maciej D (mdanilowicz) wants to merge 1 commit intomainfrom
feat/GH-2327-ii

Conversation

@mdanilowicz
Copy link
Copy Markdown
Contributor

closes #2327

This pull request streamlines the newsletter subscription logic by ensuring that the useNewsletter composable updates the subscription status directly from the API response. As a result, redundant status refresh calls in the account overview pages are removed, making the code more efficient and reducing unnecessary API requests.

Newsletter subscription logic improvements:

  • Updated useNewsletter so that newsletterStatus is set directly from the subscribe API response, keeping isNewsletterSubscriber in sync without requiring an extra status request (useNewsletter.ts). [1] [2]

Redundant code removal in account overview pages:

  • Removed the extra call to refresh newsletter status after subscribing in the vue-starter-template account overview page, since state is now updated by the composable (index.vue). [1] [2]
  • Removed the redundant newsletter status refresh in the vue-demo-store account overview page for the same reason (index.vue). [1] [2]

@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontends-starter-template-extended Ready Ready Preview, Comment May 7, 2026 5:07pm
frontends-vue-starter-template Building Building Preview, Comment May 7, 2026 5:07pm
old-frontends-demo Building Building Preview, Comment May 7, 2026 5:07pm
shopware-frontends-docs Ready Ready Preview, Comment May 7, 2026 5:07pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes newsletter subscription flows by syncing useNewsletter’s reactive status from the subscribe API response, and removing follow-up newsletter status refresh calls in account overview pages.

Changes:

  • Update useNewsletter.newsletterSubscribe() to set newsletterStatus directly from the subscribe response.
  • Remove redundant getNewsletterStatus() refresh calls after subscribe actions in vue-starter-template and vue-demo-store account overview pages.
  • Add changesets for @shopware/composables, vue-demo-store, and vue-starter-template.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/vue-starter-template/app/pages/account/index.vue Removes post-subscribe status refresh call.
templates/vue-demo-store/app/pages/account/index.vue Removes status refresh (and related UI state sync) in finally.
packages/composables/src/useNewsletter/useNewsletter.ts Syncs newsletterStatus from subscribe API response.
.changeset/swift-demo-store-newsletter.md Patch note for demo store change.
.changeset/sharp-eagles-sync.md Patch note for composables change.
.changeset/kind-starter-template-newsletter.md Patch note for starter template change.
Comments suppressed due to low confidence (1)

packages/composables/src/useNewsletter/useNewsletter.ts:85

  • newsletterSubscribe now updates newsletterStatus from the subscribe response, but newsletterUnsubscribe still leaves newsletterStatus unchanged. This can leave isNewsletterSubscriber/confirmationNeeded stale after an unsubscribe (and prevents safely removing follow-up status refreshes). Consider updating newsletterStatus in newsletterUnsubscribe as well (e.g., set it to optOut on success or update from an API response/status call).
    newsletterStatus.value = result.data.status;
    return result.data;
  }

  async function newsletterUnsubscribe(email: string) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 63 to 65
} finally {
await getNewsletterStatus();

newsletter.value = isNewsletterSubscriber.value;
newsletterDisabled.value = false;
}
Comment on lines +81 to 82
newsletterStatus.value = result.data.status;
return result.data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Newsletter status check new implementation

2 participants